#include <mips/regdef.h>

	.text
	.align	2

	.globl	length
	.ent	length
length:
	.frame	$fp, 16, ra
	.set	noreorder
	.cpload	t9
	.set	reorder
	subu	sp, sp, 16
	.cprestore 0
	sw	$fp, 4(sp)
	move	$fp, sp

	# Use v0 for the result.
	#
	li	v0, 0
length_loop:
	lb	t0, 0(a0)
	beqz	t0, length_return
	addiu	a0, a0, 1
	addiu	v0, v0, 1
	j	length_loop

length_return:
	# Destruimos el frame.
	#
	lw	$fp, 4(sp)
	addu	sp, sp, 16

	# Retorno.
	#
	j	ra
	.end	length
